package Year22_Month04.day09;

public class 移动零 {
    public void moveZeroes(int[] nums) {
        int cur = 0;
        int index = 0;
        int size = nums.length;
        while(index < size){
            if(nums[index] != 0){
                swap(nums,index,cur);
                cur++;
            }
            //不论怎样index都是要往前走的
            index++;
        }
    }
    public void swap(int[] nums,int i,int j){
        int tmp = nums[i];
        nums[i] = nums[j];
        nums[j] = tmp;
    }
}
